<template>
  <div class="app-container">
    <SearchContent :queryParams="queryParams" @query="handleQuery" @reset="resetQuery">
      <el-col :span="6">
        <el-form-item label="外部转租赁编号:" prop="rentCode" label-width="150px">
          <el-input v-model="queryParams.rentCode" clearable placeholder="请输入外部转租赁编号"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="业务来源:" prop="source">
          <el-select v-model="queryParams.source" clearable>
            <template v-for="dict in sourceList">
              <el-option :label="dict.label" :value="dict.value" :key="dict.value"></el-option>
            </template>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="客户名称:" prop="customUserName">
          <el-input v-model="queryParams.customUserName" maxlength="30" clearable placeholder="请输入客户名称"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="状态:" prop="status">
          <el-select v-model="queryParams.status" clearable>
            <template v-for="dict in statusList">
              <el-option :label="dict.label" :value="dict.value" :key="dict.value"></el-option>
            </template>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="订单编码:" prop="orderCode">
          <el-input v-model="queryParams.orderCode" maxlength="30" clearable placeholder="请输入订单编码"></el-input>
        </el-form-item>
      </el-col>
    </SearchContent>

    <div class="card-wrap card-padding">
      <div class="table-title-wrap justify-end">
        <el-button v-hasPermi="['sublease:subleaseList:export']" size="mini" type="success" @click="handleExport">导出</el-button>
      </div>
      <table-page :loading="loading" :dataList="dataList" border :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @setSizeCurrent="getList">
        <!-- 操作插槽 -->
        <template slot="tableColAc">
          <el-table-column label="操作" width="150" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <e-button size="mini" v-hasPermi="['sublease:subleaseList:edit']" type="text" @click="handleUpdate(scope.row)" v-if="scope.row.status == 1 || scope.row.auditStatus == '退回到发起人'">编辑</e-button>
              <el-button type="text" v-hasPermi="['sublease:subleaseList:detail']" @click="goToDetail(scope.row)">查看</el-button>
              <el-button type="text" v-hasPermi="['sublease:subleaseList:add']" @click="handle(scope.row)" v-if="scope.row.status == 0">去处理</el-button>
            </template>
          </el-table-column>
        </template>
        <!-- 普通列插槽 -->
        <template slot="tableCol">
          <el-table-column label="订单编码" align="center" prop="orderCode" min-width="200px" show-overflow-tooltip />
          <el-table-column label="外部转租赁编号" align="center" prop="rentCode" min-width="200px" show-overflow-tooltip />
          <el-table-column label="业务来源" align="center" prop="source" />
          <el-table-column label="客户名称" align="center" prop="customUserName" min-width="100px" show-overflow-tooltip />
          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
              <span>
                {{ scope.row.status == 0?'待处理':scope.row.status == 1?'保存':scope.row.status == 2?'已处理 ':scope.row.status == 3?'审核通过': scope.row.status == 4?'提前还车':''}}
              </span>
            </template>
          </el-table-column>
          <el-table-column label="审核状态" align="center" prop="auditStatus" />
          <!-- <el-table-column label="新车/旧车" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.carFlag == 1">
                新车
              </span>
              <span v-if="scope.row.carFlag == 2">
                新车
              </span>
            </template>
          </el-table-column> -->
          <el-table-column label="提交人" align="center" prop="submitName" />
          <el-table-column label="提交时间" align="center" prop="submitTime" min-width="120px" show-overflow-tooltip />
        </template>
      </table-page>
    </div>
  </div>
</template>

  <script>
import SearchContent from "@/components/SearchContent/index.vue";
import { getList } from "@/api/purchaseManage/sublease";

export default {
  name: "SubleaseList",
  components: {
    SearchContent,
  },
  data() {
    return {
      sourceList: [
        {
          label: "全部",
          value: "",
        },
        {
          label: "自营",
          value: "自营",
        },
        {
          label: "渠道",
          value: "渠道",
        },
      ],
      statusList: [
        {
          label: "全部",
          value: "",
        },
        {
          label: "已处理",
          value: 2,
        },
        {
          label: "待处理",
          value: 0,
        },
      ],
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      dataList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/external/outChangeRent/export",
        {
          ...this.queryParams,
        },
        `外部转租赁列表_${new Date().getTime()}.xlsx`
      );
    },
    /** 查询测试单表列表 */
    getList() {
      this.loading = true;
      getList(this.queryParams).then((res) => {
        if (res.code == "200") {
          const { rows, total } = res;
          this.dataList = this.processArray(rows);
          this.total = total;
          this.loading = false;
        }
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      (this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      }),
        this.handleQuery();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this._toPage({
        path: '/purchaseRentManage/Sublease/SubleaseView',
        name: "SubleaseView",
        query: {
          type: "edit",
          id: row.id,
        },
      });
    },
    /** 查看 */
    goToDetail(row) {
      this._toPage({
        path: '/purchaseRentManage/Sublease/SubleaseView',
        name: "SubleaseView",
        query: {
          type: "view",
          id: row.id,
        },
      });
    },
    /** 去处理 */
    handle(row) {
      this._toPage({
        path: '/purchaseRentManage/Sublease/SubleaseView',
        name: "SubleaseView",
        query: {
          type: "edit",
          id: row.id,
        },
      });
    },
  },
};
</script>


  <style lang="scss" scoped>
.pagination-container {
  padding: 0 20px 50px !important;
}

.form-dialog {
  ::v-deep .el-dialog__header {
    padding: 10px 20px;
    border-bottom: 1px solid #dcdfe6;

    .el-dialog__headerbtn {
      top: 15px;
    }
  }

  .box-card {
    margin-bottom: 20px;

    .card-title {
      font-size: 16px;
      position: relative;
      margin-left: 8px;
      padding: 0;
    }

    .card-title::after {
      content: "";
      width: 4px;
      height: 18px;
      background-color: aqua;
      display: block;
      position: absolute;
      left: -12px;
      top: 2px;
    }
  }
}
</style>

